﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage<LoginModel>" %>

<asp:Content ID="Content1" ContentPlaceHolderID="MainContent" runat="server">
	<div id="sessions-new" class="content-wrapper float-container">
		<ul id="sales-button">
			<li>
				<%=Html.ActionLink("注册新用户","Register","Home",null,new {@class="thickbox icon logo"}) %>
			</li>
			<%--<li><a href="#" class="thickbox icon phone" title=""><span></span></a></li>--%>
		</ul>
		<%--<% Html.EnableClientValidation(); %>--%>
		<% using (Html.BeginForm())
	 { %>
		<h2>
			<%=Html.Encode(Model.SubTitle)%></h2>
		<hr class="top-seperator" />
		<fieldset>
			<legend>登录</legend>
			<p>
				<%=Html.LabelFor(c => c.UserName)%>
				<%=Html.TextBoxFor(c => c.UserName)%>
				<%--<%=Html.ValidationMessageFor(c => c.UserName) %>--%>
			</p>
			<p>
				<%=Html.LabelFor(c => c.Password)%>
				<%=Html.PasswordFor(c => c.Password)%>
				<%--<%=Html.ValidationMessageFor(c => c.Password) %>--%>
				<span>
					<%=Html.ActionLink("忘记密码?", "ForgotPassword")%></span>
			</p>
			<p>
				<%=Html.CheckBoxFor(c => c.RememberMe, new { @class="checkbox"})%>
				<%=Html.LabelFor(c => c.RememberMe)%>
			</p>
		</fieldset>
		<div class="buttons action-buttons">
			<a class="btn large-action-btn"><span>
				<input class="" name="commit" type="submit" />登 录</span></a>
		</div>
		<%} %>
		<div class="clear">
			<!-- force clear -->
		</div>
	</div>

	<script type="text/javascript">
		$(document).ready(function() {
			$("form").validate({
				rules: {
					UserName: "required",
					Password: "required"
				},
				submitHandler: function(form) {
					$.getJSON('/Home/ValidateUser', $('form').serialize(), function(data) {
						if (data.success) {
							window.location = '/Home/Index';
						}
						else {
							alert(data.message);
							//$('#FailureText').html(data.message);
						}
					});
				}
			});

			//		$('input[type="submit"]').click(function() {
			//			if (!$('form').valid()) {
			//				return false;
			//			}
			//			$.getJSON('/Home/ValidateUser', $('form').serialize(), function(data) {
			//				if (data.success) {
			//					window.location = '/Home/Index';
			//				}
			//				else {
			//					alert(data.message);
			//					//$('#FailureText').html(data.message);
			//				}
			//			});
			//			return false;
			//		});
		});
	</script>

</asp:Content>
